{% extends "base_generic.html" %}
{% block script %}
<script type="text/javascript">
  $(window).load(
    function() {
      $( "#matchDate" ).datepicker({ dateFormat: 'yy-mm-dd 00:00:00.000000' });
    });
    
    function setHomeTeam() {
      $(".homeTeamIn").val($("#homeTeam").val());
      $("#stadium").val($("#homeTeam").val());
    }  
    function setAwayTeam() {
      $(".awayTeamIn").val($("#awayTeam").val());
    }
</script>
{% endblock %}
{% block content %}
        <h1>Match</h1>
        <form action="/admin/matchs/{{ key }}/save/" method="post">
        
        <div class="line">
          <div class="field">
            <select name="homeTeam" id="homeTeam" onchange="setHomeTeam();" size="15">
              {% for team in teams %}
              <option value="{{ team.name }}"{% ifequal match.homeTeam team.name %} selected="selected"{% endifequal %}>{{ team.name }}</option>
              {% endfor %}
            </select>&nbsp;&nbsp;
            vs. 
          </div>
          <div class="field">
            <select name="awayTeam" id="awayTeam" onchange="setAwayTeam();" size="15">
              {% for team in teams %}
              <option value="{{ team.name }}"{% ifequal match.awayTeam team.name %} selected="selected"{% endifequal %}>{{ team.name }}</option>
              {% endfor %}
            </select>
          </div>
          <div class="field" style="display: none;">
            <input type="text" value="{{ match.homeTeam }}" name="team" class="homeTeamIn" />
            <input type="text" value="{{ match.awayTeam }}" name="team" class="awayTeamIn" />
          </div>
        </div>
        <div class="line">
          <div class="field">
            <label>Date:</label>
            <input id="matchDate" name="matchDate" type="text" size="30" value="{{ match.matchDate }}" />
          </div>
          <div class="field">
            <label>Jornada/ronda:</label>
            <input id="phase" name="phase" type="text" size="10" value="{{ match.phase }}" />
            <select id="phase2" name="phase2" type="text">
              <option value="Cuartos de final">Cuartos de final</option>
              <option value="Octavos de final">Octavos de final</option>
              <option value="Semifinales">Semifinales</option>
              <option value="Final">Final</option>
              <option value="1">1</option>
              <option value="2">2</option>
              <option value="3">3</option>
              <option value="4">4</option>
              <option value="5">5</option>
              <option value="6">6</option>
              <option value="7">7</option>
              <option value="8">8</option>
              <option value="9">9</option>
              <option value="10">10</option>
              <option value="11">11</option>
              <option value="12">12</option>
              <option value="13">13</option>
              <option value="14">14</option>
              <option value="15">15</option>
              <option value="16">16</option>
              <option value="17">17</option>
              <option value="18">18</option>
              <option value="19">19</option>
              <option value="20">20</option>
              <option value="21">21</option>
              <option value="22">22</option>
              <option value="23">23</option>
              <option value="24">24</option>
              <option value="25">25</option>
              <option value="26">26</option>
              <option value="27">27</option>
              <option value="28">28</option>
              <option value="29">29</option>
              <option value="30">30</option>
              <option value="31">31</option>
              <option value="32">32</option>
              <option value="33">33</option>
              <option value="34">34</option>
              <option value="35">35</option>
              <option value="36">36</option>
              <option value="37">37</option>
              <option value="38">38</option>
              <option value="39">39</option>
              <option value="40">40</option>
              <option value="41">41</option>
              <option value="42">42</option>
              <option value="43">43</option>
              <option value="44">44</option>
              <option value="45">45</option>
              <option value="46">46</option>
              <option value="47">47</option>
              <option value="48">48</option>
              <option value="49">49</option>
            </select>
          </div>
        </div>
        <div class="line">
          <div class="field">
            <label>Competición:</label>
            <select id="competition" name="competition">
              <option value="Liga">Liga</option>
              <option value="Copa del Rey">Copa del Rey</option>
              <option value="Champions League">Champions League</option>
              <option value="Europa League">Europa League</option>
              <option value="Supercopa de España">Supercopa de España</option>
              <option value="Supercopa de Europa">Supercopa de Europa</option>
              <option value="Amistoso">Amistoso</option>
            </select>
          </div>
          <div class="field">
            <label>Stadium:</label>
            <select name="stadium" id="stadium">
              {% for team in teams %}
              <option value="{{ team.name }}"{% ifequal stadiumTeam.name team.name %} selected="selected"{% endifequal %}>{{ team.name }}</option>
              {% endfor %}
            </select> - {{ stadium }}
          </div>
          <div class="field">
            <label>Temporada:</label>
            <input id="season" name="season" type="text" size="10" value="2011/2012" />
          </div>
        </div>
        <input type="submit" value="Guardar" id="save" name="save" name="save" /><br class="clear" />
      </form>
      <br class="clear" />

{% endblock %}
      